function() {
    function e() {
        i(),
        r(),
        n(),
        u(),
        o()
    }

    function t() {
        requestAnimationFrame(t),
        TWEEN.update(),
        Z && (S.geometry.verticesNeedUpdate = !0),
        b(),
        m(),
        g(),
        c(),
        I && I.update(),
        T.render()
    }

    function i() {
        M = new THREE.WebGLRenderer({
            antialias: !1,
            alpha: !0
        }),
        M.setSize(B, F),
        M.sortObjects = !1,
        M.autoClear = !1,
        M.domElement.id = "mainanim",
        document.body.appendChild(M.domElement),
        window.addEventListener("resize", d),
        window.addEventListener("orientationchange", d)
    }

    function n() {
        E = new THREE.PerspectiveCamera(ismobile ? 100 : 75, B / F, 1, 5e4),
        E.position.set(0, 0, 1e3),
        E.lookAt(new THREE.Vector3(0, 0, 0))
    }

    function r() {
        w = new THREE.Scene,
        debug || (w.fog = new THREE.FogExp2(328972, 5e-4), M.setClearColor(w.fog.color))
    }

    function o() {
        if (!ismobile) var e = new THREE.TessellateModifier(.01);
        var t = 0,
        i = ["//game.gtimg.cn/images/up/act/a20170301pre/js/obj/cpgame3.json", "//game.gtimg.cn/images/up/act/a20170301pre/js/obj/cpac5.json", "//game.gtimg.cn/images/up/act/a20170301pre/js/obj/cpbook2.json", "//game.gtimg.cn/images/up/act/a20170301pre/js/obj/cpmovie4.json", "//game.gtimg.cn/images/up/act/a20170301pre/js/obj/cpkv3.json", "//game.gtimg.cn/images/up/act/a20170301pre/js/obj/qr.json"],
        n = [700, 700, 1e3, 1200, 1500, 500],
        r = [[72, 30, 60], [0, -30, 0], [0, 0, 0], [90, 180, 0], [10, 0, 0], [0, 0, 0]],
        o = [[ - 400, 100, 0], [400, 0, 0], [ - 500, 150, 0], [0, 0, 0], [0, -500, 0], [0, 0, 0]];
        ismobile && (n = [700, 700, 1e3, 1200, 2e3, 500], r = [[72, 30, 60], [0, -30, 0], [10, 0, 0], [90, 180, 0], [ - 10, 0, 0], [0, 0, 0]], o = [[ - 250, 200, 0], [400, 50, 0], [ - 100, 250, 0], [0, 200, 0], [0, -800, 0], [0, 0, 0]]),
        i.forEach(function(s, c) { 
        	(new THREE.JSONLoader).load(s, function(h) {
                $("body").trigger("resloading"),
                resloaded += .1;
                s.match(/.*\/(.*?\.json)$/)[1];
                c !== i.length - 2 || ismobile || e.modify(h),
	                ismobile && h.vertices.length > 4e3,
	                h.center(),
	                h.normalize(),
	                h.rotateX(3.14 * r[c][0] / 180),
	                h.rotateY(3.14 * r[c][1] / 180),
	                h.rotateZ(3.14 * r[c][2] / 180),
	                h.scale(n[c], n[c], n[c]),
	                h.translate(o[c][0], o[c][1], o[c][2]);
                
                var l = [];
                h.vertices.forEach(function() {
                    l.push(new THREE.Color("hsl(160, 100%, 100%)"))
                });
                for (var u = 0; u < h.faces.length; u++) {
                    var p = h.faces[u];
                    l[p.a] = p.vertexColors[0] || new THREE.Color("hsl(" + (160 + 0 * Math.random()) + ", 100%, 100%)"),
                    l[p.b] = p.vertexColors[1] || new THREE.Color("hsl(" + (160 + 0 * Math.random()) + ", 100%, 100%)"),
                    l[p.c] = p.vertexColors[2] || new THREE.Color("hsl(" + (160 + 0 * Math.random()) + ", 100%, 100%)")
                }
                h.colors = l,
                j[c] = h,
                t++,
                t === i.length && a()
            })
        })
    }

    function a() {
        var e = new THREE.Geometry,
        t = 1e3,
        i = Math.max.apply(null, j.map(function(e) {
            return e.vertices.length
        }));
        e.colors = [];
        for (var n = 0; i > n; n++) e.vertices.push(1e6 > n ? new THREE.Vector3(_( - 1 * t, t), _( - 1 * t, t), _( - 12 * t, 1 * t)) : new THREE.Vector3(0, 0, 0)),
        e.colors.push(new THREE.Color("hsl(" + (180 + 10 * Math.random()) + ", 100%, 100%)"));
        var r = new THREE.TextureLoader;
        r.crossOrigin = "",
        r.load("//game.gtimg.cn/images/up/act/a20170301pre/images/three/gradient.png",
        function(i) {
            var n = new THREE.PointsMaterial({
                size: 5,
                map: i,
                blending: THREE.AdditiveBlending,
                depthWrite: !1,
                transparent: !0,
                vertexColors: THREE.VertexColors
            });
            S = new THREE.Points(e, n),
            S.position.z = -1 * t,
            h()
        })
    }

    function s() {
        var e = new THREE.Geometry,
        t = 1500,
        i = 500;
        e.colors = [];
        for (var n = 0; i > n; n++) e.vertices.push(new THREE.Vector3(_( - 1 * t, t), _( - 1 * t, t), _( - 1 * t, t))),
        e.colors.push(new THREE.Color("hsl(" + (190 + 30 * Math.random()) + ", 0%, 100%)"));
        var r = new THREE.TextureLoader;
        r.crossOrigin = "",
        r.load("//game.gtimg.cn/images/up/act/a20170301pre/images/three/gradient.png",
        function(i) {
            var n = new THREE.PointsMaterial({
                size: 7,
                map: i,
                blending: THREE.AdditiveBlending,
                depthWrite: !1,
                transparent: !0,
                vertexColors: THREE.VertexColors
            });
            A = new THREE.Points(e, n),
            A.position.z = -1 * t,
            A.position.x = -.1 * t,
            R = new THREE.Points(e, n),
            R.position.z = -1.1 * t,
            R.position.y = -.2 * t,
            L = new THREE.Points(e, n),
            L.position.z = -1.2 * t,
            w.add(A),
            w.add(R),
            w.add(L)
        })
    }

    function c() {
        A && introed && (A.rotation.x -= W.firefly / 1.5, R.rotation.y += W.firefly, L.rotation.z += W.firefly / 2)
    }

    function h() {
        C = new THREE.Object3D,
        C.add(S);
        for (var e = ["//game.gtimg.cn/images/up/act/a20170301pre/images/three/banner1.png", "//game.gtimg.cn/images/up/act/a20170301pre/images/three/banner2.png", "//game.gtimg.cn/images/up/act/a20170301pre/images/three/banner3.png", "//game.gtimg.cn/images/up/act/a20170301pre/images/three/banner4.png"], t = 3e3, i = -1e3, n = new THREE.PlaneBufferGeometry(1024, 512), r = 0, o = 0; o < e.length; o++) !
        function(o) {
            var a = new THREE.TextureLoader;
            a.crossOrigin = "",
            a.load(e[o],
            function(a) {
                $("body").trigger("resloading"),
                resloaded += .1;
                var s = new THREE.MeshLambertMaterial({
                    side: THREE.DoubleSide,
                    color: 16777215,
                    map: a,
                    transparent: !0
                });
                s.map = a;
                var c = new THREE.Mesh(n, s);
                c.position.z = i - t * o,
                C.add(c),
                r++,
                r === e.length && (C.position.z = -2e3, w.add(C), $("body").trigger("resloaded"))
            })
        } (o)
    }

    function l() {
        for (var e, i = debug ? 2e3: 25e3, n = 5, r = 1e3, o = 3e3, a = new TWEEN.Tween(S.position).to({
            z: .1
        },
        i).easing(TWEEN.Easing.Linear.None).delay(1e3).onUpdate(function() {}).onStart(function() {}).onComplete(function() {}), s = [], c = 0; n > c; c++) e = new TWEEN.Tween(C.position).to({
            z: r + o * c
        },
        i / n).easing(TWEEN.Easing.Quintic.InOut).onUpdate(function() {}).onStart(function() {}).onComplete(function() {}),
        s.push(e);
        for (var c = 0; c < s.length - 1; c++) s[c].chain(s[c + 1]);
        s[0].start(),
        a.start(),
        setTimeout(function() {
            introed || (v(), $("body").trigger("introed"))
        },
        i - 1e3),
        t()
    }

    function u() {
        var e = new THREE.RenderPass(w, E),
        t = new THREE.BloomPass(.75),
        i = new THREE.FilmPass(.5, .5, 1500, !1);
        P = new THREE.ShaderPass(THREE.FocusShader),
        P.uniforms.screenWidth.value = window.innerWidth,
        P.uniforms.screenHeight.value = window.innerHeight,
        P.renderToScreen = !0,
        T = new THREE.EffectComposer(M),
        T.addPass(e),
        T.addPass(t),
        T.addPass(i),
        T.addPass(P)
    }

    function p(e) {
        isnowpop || X || (V = 3e-4 * (e.clientX - z), k = 1e-4 * (e.clientY - H))
    }

    function d() {
        E.aspect = window.innerWidth / window.innerHeight,
        E.updateProjectionMatrix(),
        M.setSize(window.innerWidth, window.innerHeight),
        T.reset(),
        P.uniforms.screenWidth.value = window.innerWidth,
        P.uniforms.screenHeight.value = window.innerHeight
    }

    function f() {
        TWEEN.removeAll(),
        S.position.z = .1,
        v(),
        $("body").trigger("introed")
    }

    function m() {
        S && introed && stormed && !X && (G += W.qrcode, S.rotation.y = .2 * Math.sin(G))
    }

    function g() {
        X && (V = 0, k = 0),
        w.rotation.y += (V - w.rotation.y) / 50,
        w.rotation.x += (k - w.rotation.x) / 50
    }

    function v() {
        var e = 1e3;
        w.remove(C),
        S.geometry.vertices.forEach(function(t) {
            t.x = _( - 1 * e, 1 * e),
            t.y = _( - 1 * e, 1 * e),
            t.z = _( - 1 * e, 1 * e)
        }),
        S.geometry.verticesNeedUpdate = !0,
        w.add(S),
        document.body.addEventListener("mousemove", p),
        s()
    }

    function y() {
        S.rotation.y = 3.14 * -.4,
        new TWEEN.Tween(S.rotation).easing(TWEEN.Easing.Quintic.Out).to({
            y: 0
        },
        1e4).onUpdate(function() {}).onComplete(function() {
            stormed = !0
        }).start()
    }

    function x(e) {
        q = "undefined" == typeof e ? ++q % j.length: e % j.length,
        X = e === j.length - 2 ? !0 : !1,
        Z = !0,
        clearTimeout(U),
        U = setTimeout(function() {
            Z = !1
        },
        Y * (J + 2));
        var t = j[q];
        S.material.tween || (S.material.tween = new TWEEN.Tween(S.material).easing(TWEEN.Easing.Exponential.In)),
        S.material.tween.stop(),
        ismobile || (q === j.length - 1 ? (W.qrcode = W.qrcodeFAST, clearTimeout(N), S.material.map = null, S.material.needsUpdate = !0, 20 !== S.material.size && S.material.tween.to({
            size: 20
        },
        Y * (J + 1)).start()) : (W.qrcode = W.qrcodeSLOW, N = setTimeout(function() {
            var e = new THREE.TextureLoader;
            e.crossOrigin = "",
            e.load("//game.gtimg.cn/images/up/act/a20170301pre/images/three/gradient.png",
            function(e) {
                S.material.map = e,
                S.material.needsUpdate = !0
            })
        },
        Y * (J + 1)), 5 !== S.material.size && S.material.tween.to({
            size: 5
        },
        Y * (J + 1)).start())),
        S.geometry.vertices.forEach(function(e, i) {
            var n = S.geometry.colors[i],
            r = i % t.vertices.length,
            o = t.vertices[r],
            a = t.colors[r] || new THREE.Color("hsl(" + (160 + 3 * Math.random()) + ", 100%, 100%)"),
            s = [n.r, n.g, n.b],
            c = [a.r - s[0], a.g - s[1], a.b - s[2]];
            e.tweenvtx || (e.tweenvtx = new TWEEN.Tween(e).easing(TWEEN.Easing.Exponential.In).onUpdate(function(e) {
                n.r = s[0] + c[0] * e,
                n.g = s[1] + c[1] * e,
                n.b = s[2] + c[2] * e
            }).onStart(function() {}).onComplete(function() {
                e.tweenvtx.isplaying = !1
            }), e.tweenvtx.isplaying = !1),
            e.tweenvtx.stop(),
            e.tweenvtx.isplaying = !0,
            e.tweenvtx.to({
                x: o.x,
                y: o.y,
                z: o.z
            },
            Y).delay(J * Y * Math.random()).start()
        }),
        D || (D = new TWEEN.Tween(W).easing(TWEEN.Easing.Exponential.In), O = new TWEEN.Tween(W).easing(TWEEN.Easing.Exponential.In)),
        D.stop(),
        O.stop(),
        D.to({
            firefly: W.fireflyFAST
        },
        .5 * Y * (J + 1)).chain(O),
        O.to({
            firefly: W.fireflySLOW
        },
        .5 * Y * (J + 1)),
        D.start(),
        Y = 1e3,
        J = .5
    }

    function b() {
        if (q % j.length === j.length - 2) {
            var e = j[q % j.length],
            t = {
                x: 0,
                y: -150,
                z: 0
            };
            S.geometry.vertices.forEach(function(i, n) {
                if (!i.tweenvtx.isplaying) {
                    var r = n % e.vertices.length,
                    o = e.vertices[r],
                    a = Math.sqrt(Math.pow(i.x - t.x, 2) + Math.pow(i.z - t.z, 2));
                    i.y = o.y + Math.sin(a / 70 + Q) * a / 30
                }
            }),
            S.geometry.verticesNeedUpdate = !0,
            Q -= .015
        }
    }

    function _(e, t) {
        return Math.random() * (t - e) + e
    }
    var w, E, M, T, S, A, R, L, P, C, I, U, N, D, O, B = window.innerWidth,
    F = window.innerHeight,
    z = window.innerWidth / 2,
    H = window.innerHeight / 2,
    G = 0,
    V = 0,
    k = 0,
    j = [],
    W = {
        firefly: .002,
        fireflySLOW: .002,
        fireflyFAST: .04,
        qrcode: .001,
        qrcodeFAST: .01,
        qrcodeSLOW: .001
    },
    X = !1,
    q = -1,
    Y = 1500,
    Z = !1,
    J = 1.7,
    Q = 0;
    e(),
    window.toggleParticle = x,
    window.introBox = l,
    window.skipIntrobox = f,
    window.startStorm = y
} ();